package com.yuanwushe.blue.view;

import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.yuanwushe.blue.onceandroid.R;

/**
 * Created by blue on 2018/5/27.
 */

public class BarView extends LinearLayout {
    private Context mContext;
    public BarView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        mContext = context;
        LayoutInflater.from(context).inflate(R.layout.activity_bar, this);
        TextView leftButton = findViewById(R.id.left_button);
        TextView rightButton = findViewById(R.id.right_button);
        TextView title = findViewById(R.id.bar_title);
        leftButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                toast("左边");
            }
        });
        rightButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                toast("右边");
            }
        });
    }

    private void toast(String text) {
        Toast.makeText(mContext, text, Toast.LENGTH_SHORT).show();
    }
}
